package com.hanliy.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Calendar;

/**
 * @author hanyulin
 * @apiNote MybatisPlus配置类
 * @date 2021/12/3 11:30
 */
@Configuration
public class MybatisPlusConfig implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", Calendar.getInstance().getTime(), metaObject);
        this.setFieldValByName("updateTime", Calendar.getInstance().getTime(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", Calendar.getInstance().getTime(), metaObject);
    }
}
